package common;

import com.jfinal.kit.PathKit;
import com.jfinal.kit.PropKit;
import com.jfinal.plugin.activerecord.generator.Generator;
import com.jfinal.plugin.hikaricp.HikariCpPlugin;

import common.kit.PropKits;

public class commom {
    public static void main(String[] args){
        generateDb();
    }

    private static void generateDb() {
        String baseModelPkg = "model.base";
        String baseModelDir = PathKit.getWebRootPath() + "/src/main/java/model/base";
        String modelPkg = "model";
        String modelDir = baseModelDir + "/..";

        PropKit.use("main_config_dev.properties");
        HikariCpPlugin hikariCpPlugin = new HikariCpPlugin(PropKits.getJdbcUrl(), PropKits.getJdbcUser(), PropKits.getJdbcPsw());
        hikariCpPlugin.start();
        Generator generator = new Generator(hikariCpPlugin.getDataSource(), baseModelPkg, baseModelDir, modelPkg, modelDir);
//        Excluded specific table
//        generator.addExcludedTable("sys_user_module_rel");
        //Generate dao in model
        generator.setGenerateDaoInModel(true);
//        generator.setBaseModelTemplate("base_model_template.jf");
        //Generate remark in basemodel
        generator.setGenerateRemarks(true);
        //Ignore prefix t_
        generator.setRemovedTableNamePrefixes("t_");
        generator.generate();
    }
}
